dir="/mnt/nas/datasets/diction"
dates=("0808" 
        "0811" "0812" "0813" "0814" "0815"
        "0818" "0819" "0820" "0821" "0822"
        "0825" "0826" "0827" "0828" "0829"
        "0901" "0902" "0903" "0904" "0905"
        "0908" "0909" "0910" "0911" "0912"
        "0915" "0916" "0917")
categories=("coat" "sweater" "leather")

# 初始化一个关联数组来存储每个类别的总clo(diff)数量
declare -A category_totals

# 还存在 jpeg 的情况 虽然不多

for category in "${categories[@]}"; do
    # 初始化当前类别的总和为0
    category_totals[$category]=0

    # leather 到 0825 为止 if date > 0825 and category=leather then continue
    # 如果类别是leather且日期大于0825，则跳过本次循环
    for date in "${dates[@]}"; do
        if [[ "$category" == "leather" && "$date" > "0825" ]]; then
            continue
        fi

        query_dir="$dir"/"$category""$date"_img_front_back
        bash restore.sh "$query_dir"

        count=$(grep -c "\.jpg" "$query_dir"/names.txt)
        # count2=$(grep -c "\.jpg" "$dir"/"$category""$date"_img_clo/names.txt)
        # count3=$(grep -c "\.jpg" "$dir"/"$category""$date"_img_clo_diff/names.txt)

        # 累加到当前类别的总和中
        category_totals[$category]=$((category_totals[$category] + count))

        echo "$category Date: $date, JPG count: $count"
        # echo $category "Date: $date clo(diff+sim), JPG count: $count2"
        # echo $category "Date: $date clo(diff), JPG count: $count3"
        # echo
    done
done    

# 输出每个类别的clo(diff)总数量
echo "---> Total clo(diff) counts per category: <---"
for category in "${categories[@]}"; do
    echo "$category: ${category_totals[$category]}"
done